package com.oocl.homework.crm.command;

import com.oocl.homework.crm.datastruct.Executeable;
import com.oocl.homework.crm.model.Filterable;
import com.oocl.homework.crm.model.Result;
import com.oocl.homework.crm.util.CommandUtil;

public class DeleteCommand<T> extends Command<T> {

	public DeleteCommand(String command) {
		super(command);
	}
	

//	@Override
//	public void filter(Filterable filterable) {
//		super.filter(filterable);
//		if(result.getCode()==-1){
//			return;
//		}else{
//			splitCommandParameterAttributes();
//			if(result.getCode()==-1){
//				return ;
//			}
//			Result filterResult = filterable.filter(getCommandParameterAttributes());
//			if (filterResult.getCode()==-1) {
//				result =  filterResult;
//				return;
//			}
//		}
//		String[] attributes = getCommandParameterAttributes();
//		int count = 0;
//		for (int i = 0; i < attributes.length; i++) {
//			if (attributes[i].equals("id")) {
//				count++;
//			if(!CommandUtil.isNumeric(getCommandParameters()[i].split(":")[1])){
//				result.setCode(-1);
//				result.setMessage("id must be digit");
//				return;
//			}
//			}
//			
//		}
//		if (count==0) {
//			result.setCode(-1);
//			result.setMessage("need id");
//		}
//		
//	}
	
	
	@Override
	public void filter(Filterable filterable) {
		super.filter(filterable);
		super.filterId();
	}
	
	@Override
	public void executeCommand(Executeable<T> executeable,T t) {
		super.executeCommand(executeable, t);
		executeable.delete(t);
		
	}
	
	
	@Override
	public void display() {
		super.display();
		CommandDoc.printDeleteCommandHelp();
		
	}

}
